]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
brightnessManager: Make BrightnessScale destroyable
authorSebastian Keller <skeller@gnome.org>
Fri, 4 Sep 2026 11:52:27 +0000 (13:52 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 13 Sep 2026 17:39:10 +0000 (19:39 +0200)
`BrightnessScale` is being connected to with `connectObject()` from a
non-destroyable object (`BrightnessManager`) and it itself also connects
to non-destroyable objects using this method. Since none of these
objects are triggering the signal cleanup in the signal tracker, this
was causing all of the involved objects, including the signal tracker to
get leaked. This was happening for example on anything that triggers the
`monitors-changed` signal, such as switching VTs.

To fix this make `BrightnessScale` destroyable and destroy them when
necessary.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4385>
(cherry picked from commit 457f781e16fa5a309292fb1b920e64f29362afca)

js/misc/brightnessManager.js

index feb38ecab440a0b948b39f85595c77d47203d79f..15bbc49c6e7335d662046df7a980f91e3beb7f4b 100644 (file)
@@ -4,6 +4,7 @@ import Meta from 'gi://Meta';
 import Shell from 'gi://Shell';
 
 import * as Main from '../ui/main.js';
+import * as SignalTracker from '../misc/signalTracker.js';
 
 const SCALE_VALUE_N_STEPS = 20;
 const SCALE_VALUE_CHANGE_EPSILON = 0.001;
@@ -141,6 +142,7 @@ export const BrightnessManager = GObject.registerClass({
                     .some(m => m.get_backlight() && m.is_active());
             });
 
+        this._monitorScales.values().forEach(scale => scale.destroy());
         this._monitorScales.clear();
 
         for (const monitor of monitors) {
@@ -283,6 +285,9 @@ export const BrightnessScale = GObject.registerClass({
             GObject.ParamFlags.READWRITE,
             0, 1.0, 1.0),
     },
+    Signals: {
+        'destroy': {},
+    },
 }, class BrightnessScale extends GObject.Object {
     constructor(name, value = 1.0, nSteps = SCALE_VALUE_N_STEPS) {
         super();
@@ -327,7 +332,12 @@ export const BrightnessScale = GObject.registerClass({
         this._value = Math.clamp(value, 0.0, 1.0);
         this.notify('value');
     }
+
+    destroy() {
+        this.emit('destroy');
+    }
 });
+SignalTracker.registerDestroyableType(BrightnessScale);
 
 const MonitorBrightnessScale = GObject.registerClass({
     Signals: {